<template>
    <div>
        <video id="video" autoplay="" style='width:640px;height:480px'></video>
        <button id="paizhao">拍照</button>
        <canvas id="canvas" width="640" height="480"></canvas>
        <input type="file" accept="image/*" capture="camera">
        <input type="file" accept="video/*" capture="camcorder">
        <input type="file" accept="audio/*" capture="microphone">

    </div>
</template>

<script>
    export default {
        name: 'HelloWorld',
        data() {
            return {
                msg: '',
                checked: ""
            }
        },
        mounted() {
            var video = document.getElementById("video");
            var context = canvas.getContext("2d");
            var errocb = function () {
                console.log("sth srong");
            }
            if (navigator.getUserMedia) {
                navigator.getUserMedia({ "video": true }, function (stream) {
                    video.src = stream;
                    video.play();
                }, errocb);
            } else if (navigator.webkitGetUserMedia) {
                navigator.webkitGetUserMedia({ "video": true }, function (stream) {
                    video.src = window.webkitURL.createObjectURL(stream);
                    video.play();
                }, errocb);
            }
            document.getElementById("paizhao").addEventListener("click", function () {
                context.drawImage(video, 0, 0, 640, 480);
            });
        }
    }
</script>